<template>
  <div class="main">
    <!--  左边内容-->
    <div style="margin-right: 0;width: 70%;height: 100%;float: left">
      <!--  头部个人信息卡片-->
      <a-card hoverable :style="{ width: '94%', height:'22%',marginTop: '20px',marginLeft:'4%' }" class="Card">
        <!--        详细信息-->
        <el-row>
          <el-col :span="21">
            <el-descriptions style="width: 100%;height:100%;margin-top: 0" v-if="user.identityId=='10'">
              <!--      头像-->
              <el-descriptions-item>
                <el-avatar :size="60">
                  <img :src="BASE_URL+userform.userImg" style="width: 50px;height: 50px; border-radius: 25px; object-fit: cover;margin-left: 5%;" class="scale">
                </el-avatar>
                <h4 style="margin-left: 70px;margin-top: -48px" >{{userform.realName}}</h4>
              </el-descriptions-item>
              <!--      头像结束-->
              <el-descriptions-item label="出生日期">{{seeker.birthday}}</el-descriptions-item>
              <el-descriptions-item label="所在地区" >{{seeker.birthdayPlace}}</el-descriptions-item>
              <el-descriptions-item label="" ></el-descriptions-item>
              <el-descriptions-item label="性别" >{{userform.gender}}</el-descriptions-item>
              <el-descriptions-item label="学历" >
                {{seeker.educationBackground}}
                <el-tag size="small">{{seeker.major}}</el-tag>
                <el-tag size="small" style="margin-left: 12px" >{{seeker.degree}}</el-tag>
              </el-descriptions-item>
              <el-descriptions-item label="" ></el-descriptions-item>
              <el-descriptions-item label="期望岗位">{{seeker.expectedJob}}</el-descriptions-item>
              <el-descriptions-item label="毕业时间">{{seeker.graduationTime}}</el-descriptions-item>
              <el-descriptions-item label="" ></el-descriptions-item>
              <el-descriptions-item label="昵称" >{{userform.nickname}}</el-descriptions-item>
              <el-descriptions-item label="联系方式" >
                {{userform.phone}}
                <el-tag size="small" >{{userform.email}}</el-tag>
                <el-tag size="small" style="margin-left: 12px" >{{userform.wechatId}}</el-tag>
              </el-descriptions-item>
            </el-descriptions>
            <el-descriptions style="width: 100%;height:100%;margin-top: 0" v-if="user.identityId=='20'">
              <!--      头像-->
              <el-descriptions-item>
                <el-avatar :size="60"
                           src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
                />
                <h4 style="margin-left: 70px;margin-top: -48px" >{{userform.realName}}</h4>
              </el-descriptions-item>
              <!--      头像结束-->
              <el-descriptions-item label="公司">{{HR.corporateName}}</el-descriptions-item>
              <el-descriptions-item label="职位" >{{HR.position}}</el-descriptions-item>
              <el-descriptions-item label="" ></el-descriptions-item>
              <el-descriptions-item label="性别" >{{userform.gender}}</el-descriptions-item>
              <el-descriptions-item label="" >
              </el-descriptions-item>
              <el-descriptions-item label="" ></el-descriptions-item>
              <el-descriptions-item label="">{{}}</el-descriptions-item>
              <el-descriptions-item label="">{{}}</el-descriptions-item>
              <el-descriptions-item label="" ></el-descriptions-item>
              <el-descriptions-item label="昵称" >{{userform.nickname}}</el-descriptions-item>
              <el-descriptions-item label="联系方式" >
                {{userform.phone}}
                <el-tag size="small" >{{userform.email}}</el-tag>
                <el-tag size="small" style="margin-left: 12px" >{{userform.wechatId}}</el-tag>
              </el-descriptions-item>
            </el-descriptions>
          </el-col>
          <el-col :span="3">
            <el-row>
              <!--          账号弹窗-->
              <a-button type="primary" style="margin-left: 20px;margin-top: 20px;padding: 13px;border-radius: 10px;" @click="handleClick">账号管理</a-button>
            </el-row>
            <el-row>
              <!--          信息弹窗-->
              <a-button v-if="user.identityId=='10'" type="primary" style="margin-left: 20px;margin-top: 20px;padding: 13px;border-radius: 10px;" @click="handleClickseeker">信息编辑</a-button>
            </el-row>
            <el-row>
              <!--          信息弹窗-->
              <a-button v-if="user.identityId=='20'" type="primary" style="margin-left: 20px;margin-top: 20px;padding: 13px;border-radius: 10px;" @click="handleClickHR">HR编辑</a-button>
            </el-row>
          </el-col>
        </el-row>
        <!--详细信息结束-->
      </a-card>
      <!--      标签页-->
      <div style="width: 94%;height:60vh;background-color: white;margin-top: 5px;margin-left: 4%;border-radius: 10px">
        <a-tabs default-active-key="1">
          <!--        @click=getDeliverData("已投递")-->
          <a-tab-pane key="1" >
            <template #title>
              <el-icon><Pointer /></el-icon> 已投递
            </template>
            <div v-if="deliverData.length!=0">
              <!--            内容-->
              <el-scrollbar height="58vh">
                <a-space direction="vertical" size="small" v-for="item in deliverData" :key="item" class="scrollbar-demo-item">
                  <a-descriptions :data="item" :title=item.corporateName align="left" style=" margin-left: 15px" >
                    <a-descriptions-item label="招聘职位" >{{item.recruitmentPosition}}</a-descriptions-item>
                    <a-descriptions-item label="工作地点" >{{item.companyAddress}}</a-descriptions-item>
                    <a-descriptions-item label="待遇" >{{item.positionTreatment}}</a-descriptions-item>
                    <a-descriptions-item label="投递时间" >{{ formatCreateTime(item.createTime) }}</a-descriptions-item>
                    <a-descriptions-item label="简历状态" >{{item.resumeStatus}}</a-descriptions-item>
                    <a-button type="outline"  @click = "goToJobDetail(item.recruitmentInformationId)">查看详情</a-button>
                  </a-descriptions>
<!--                  todo-->

<!--                  <a-button type="outline" style="float: right;margin-right: -400%;margin-top: -50%">查看详情</a-button>-->
                </a-space>
              </el-scrollbar>
              <!--内容结束-->
            </div>
            <a-empty v-else>
              <template #image>
                <img src="../../assets/img/user/YTD.svg">
              </template>
              快去投递吧
            </a-empty>
          </a-tab-pane>
          <!--        @click=getDeliverData("已通过")-->
          <a-tab-pane key="2" >
            <template #title>
              <el-icon><VideoCamera /></el-icon> 已通过
            </template>
                <div v-if="deliverOfPassedData.length!=0">
                <el-scrollbar height="58vh">
                  <a-space direction="vertical" size="small" v-for="item in deliverOfPassedData" :key="item" class="scrollbar-demo-item">
                    <a-descriptions :data="item" :title=item.corporateName align="left" style=" margin-left: 15px;" >
                      <a-descriptions-item label="招聘职位" >{{item.recruitmentPosition}}</a-descriptions-item>
                      <a-descriptions-item label="工作地点" >{{item.companyAddress}}</a-descriptions-item>
                      <a-descriptions-item label="待遇" >{{item.positionTreatment}}</a-descriptions-item>
                      <a-descriptions-item label="投递时间" >{{ formatCreateTime(item.createTime) }}</a-descriptions-item>
                      <a-descriptions-item label="简历状态" >{{item.resumeStatus}}</a-descriptions-item>
                      <a-button type="outline"  @click = "goToJobDetail(item.recruitmentInformationId)">查看详情</a-button>
                    </a-descriptions>
                  </a-space>
                </el-scrollbar>
            </div>
                <a-empty v-else>
                  <template #image>
                    <img src="../../assets/img/user/MS.svg">
                  </template>
                  快去预约面试吧
                </a-empty>
                <!--              </a-tab-pane>-->
          </a-tab-pane>
          <a-tab-pane key="3" >
            <!--          @click=getDeliverData("已拒绝")-->
            <template #title>
              <el-icon><Pointer /></el-icon> 已拒绝
            </template>
            <div v-if="deliverRejectedData.length!=0">
              <!--            内容-->
              <el-scrollbar height="58vh">
                <a-space  direction="vertical" size="small" v-for="item in deliverRejectedData" :key="item" class="scrollbar-demo-item">
                  <a-descriptions :data="item" :title=item.corporateName align="left" style=" margin-left: 15px;" >
                    <a-descriptions-item label="招聘职位" >{{item.recruitmentPosition}}</a-descriptions-item>
                    <a-descriptions-item label="工作地点" >{{item.companyAddress}}</a-descriptions-item>
                    <a-descriptions-item label="待遇" >{{item.positionTreatment}}</a-descriptions-item>
                    <a-descriptions-item label="投递时间" >{{ formatCreateTime(item.createTime) }}</a-descriptions-item>
                    <a-descriptions-item label="简历状态" >{{item.resumeStatus}}</a-descriptions-item>
                    <a-button type="outline"  @click = "goToJobDetail(item.recruitmentInformationId)">查看详情</a-button>
                  </a-descriptions>
                  </a-space>
              </el-scrollbar>
              <!--内容结束-->
            </div>
            <a-empty v-else>
              <template #image>
                <img src="../../assets/img/user/YTD.svg">
              </template>
              没有已拒绝的申请
            </a-empty>
          </a-tab-pane>

        </a-tabs>
      </div>
      <!--      标签页结束-->

    </div>
    <div>


    </div>
    <!--右边内容-->
    <div style="width: 29%;height: 93vh;float: right;margin-right: 1%">
<!--      &lt;!&ndash;    曝光统计&ndash;&gt;-->
<!--      <div class="CardRS" style=" margin-top: 20px;">-->
<!--        <div>-->
<!--          <a-card :style="{ width: '100%' ,height:'50%'}"  hoverable>-->
<!--            <p style="font-size: 15px;color: #6c4295;font-weight: bold"><el-icon><Avatar /></el-icon> 为您智能推荐职位：</p>-->
<!--          </a-card>-->
<!--          <el-scrollbar height="36vh"  v-if="1">-->
<!--            <n-list class="scrollbar-demo-R1" v-for="collect in collectedData" :key="collect">-->
<!--              <template #header>-->
<!--                <a-space @click = "goToJobDetail(collect.id)">-->
<!--                  <a-avatar size="35" style="margin-left: 7%">-->
<!--                    <img-->
<!--                        :src=collect.coverPhoto-->
<!--                    />-->
<!--                  </a-avatar>-->
<!--                  <p style="margin-left: 10%;margin-top: -7.5%">{{ collect.corporateName }}</p>-->
<!--                  <p style="margin-left: 20%;margin-top: -7.5%">{{ collect.recruitmentCity }}</p>-->
<!--                  <p style="margin-left: 30%;margin-top: -7.5%">{{ collect.titleName }}</p>-->
<!--                  <p style="margin-left: 40%;margin-top: -7.5%">{{ collect.salary }}</p>-->
<!--                </a-space>-->
<!--              </template>-->
<!--            </n-list>-->
<!--          </el-scrollbar>-->
<!--        </div>-->
<!--        <div>-->
<!--          &lt;!&ndash; 为 ECharts 准备一个定义了宽高的 DOM &ndash;&gt;-->
<!--          <div id="main" style="width: 95%;height:400px;">-->

<!--          </div>-->
<!--        </div>-->
<!--      </div>-->

      <div class="CardRS" style="margin-top: 26px">
        <a-tabs>
          <a-tab-pane key="1">
            <template #title>
              <icon-calendar/> 我感兴趣
            </template>
            <div  v-if="1">
              <el-scrollbar height="36vh"  v-if="1">
                <n-list class="scrollbar-demo-R1" v-for="collect in collectedData" :key="collect">
                  <template #header>
                    <a-space @click = "goToJobDetail(collect.id)">
                      <a-avatar size="35" style="margin-left: 7%">
                        <img
                            :src=collect.coverPhoto
                        />
                      </a-avatar>
                      <p style="margin-left: 10%;margin-top: -7.5%">{{ collect.corporateName }}</p>
                      <p style="margin-left: 20%;margin-top: -7.5%">{{ collect.recruitmentCity }}</p>
                      <p style="margin-left: 30%;margin-top: -7.5%">{{ collect.titleName }}</p>
                      <p style="margin-left: 40%;margin-top: -7.5%">{{ collect.salary }}</p>
                    </a-space>
                  </template>
                </n-list>
              </el-scrollbar>
            </div>
            <!--          <a-empty v-else>-->
            <!--            <template #image>-->
            <!--              <img src="../../assets/img/user/like1.svg">-->
            <!--            </template>-->
            <!--            暂时没有HR对你感兴趣哦-->
            <!--          </a-empty>-->
          </a-tab-pane>

        </a-tabs>
      </div>

    </div>


  </div>
  <!--修改信息弹窗-->
  <a-modal v-model:visible="visibleuserform" title="账号信息" @cancel="handleCancel" @before-ok="handleBeforeOk">
    <a-form :style="{width:'400px',height:'460px'}">
      <a-form-item field="username" label="账号" >
        <a-input v-model="userform.username" placeholder="请输入账号..." />
      </a-form-item>
      <!--      <a-form-item field="password" label="密码" >-->
      <!--        <a-input v-model="userform.password" placeholder="请输入密码..." />-->
      <!--      </a-form-item>-->
      <!--      <a-form-item field="password" label="密码" >-->
      <!--        <a-input v-model="user.password" placeholder="请输入密码..." />-->
      <!--      </a-form-item>-->
      <a-form-item field="email" label="邮箱" >
        <a-input v-model="userform.email" placeholder="请输入邮箱..." />
      </a-form-item>
      <a-form-item field="phone" label="手机号" >
        <a-input v-model="userform.phone" placeholder="请输入手机号..." />
      </a-form-item>
      <a-form-item field="realName" label="姓名" >
        <a-input v-model="userform.realName" placeholder="请输入姓名..." />
      </a-form-item>
      <a-form-item field="radio" label="性别">
        <a-radio-group v-model="userform.gender">
          <a-radio value="男">男</a-radio>
          <a-radio value="女">女</a-radio>
        </a-radio-group>
      </a-form-item>
      <a-form-item field="password" label="修改头像" >
        <el-upload
            v-model:file-list="fileList"
            action="http://localhost:8080/v1/file/upload"
            name="file"
            :limit="1"
            list-type="picture-card"
            style="text-align: center;"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove">
          <img v-if="dialogImageUrl" :src="BASE_URL+dialogImageUrl" class="avatar">
          <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          <el-icon><Plus /></el-icon>
          <template #tip>
            <div class="el-upload__tip">只能上传jpg/png文件，且不超过50M</div>
          </template>
        </el-upload>
      </a-form-item>
      <a-form-item field="password" label="修改密码" >
      </a-form-item>
      <a-form-item field="password" label="旧密码" >
        <a-input v-model="user.password" placeholder="请输入旧密码..." />
      </a-form-item>
      <a-form-item field="password" label="确认密码" >
        <a-input v-model="user.password1" placeholder="请输入新密码..." />
      </a-form-item>
      <a-form-item field="password" label="确认密码" >
        <a-input v-model="user.password2" placeholder="请输入确认新密码..." />
      </a-form-item>
    </a-form>
  </a-modal>
  <!--  修改信息弹窗-->
  <!--修改seekerfrom弹窗-->
  <a-modal v-model:visible="visibleseeker" title="账号信息" @cancel="handleCancelseeker" @before-ok="handleBeforeOkseeker">
    <a-form :style="{width:'400px',height:'600px'}">
      <a-form-item field="identity" label="身份" >
        <a-input v-model="seekerform.identity" placeholder="请输入身份..." />
      </a-form-item>
      <a-form-item field="lookforStatus" label="求职状态" >
        <a-input v-model="seekerform.lookforStatus" placeholder="请输入求职状态..." />
      </a-form-item>
      <a-form-item field="personalAdvantage" label="个人优势" >
        <a-input v-model="seekerform.personalAdvantage" placeholder="请输入个人优势..." />
      </a-form-item>
      <a-form-item field="graduateTime" label="毕业时间" >
        <a-input v-model="seekerform.graduateTime" placeholder="请输入毕业时间..." />
      </a-form-item>
      <a-form-item field="birthday" label="出生日期" >
        <a-input v-model="seekerform.birthday" placeholder="请输入出生日期..." />
      </a-form-item>
      <a-form-item field="birthdayPlace" label="出生地" >
        <a-input v-model="seekerform.birthdayPlace" placeholder="请输入出生地..." />
      </a-form-item>
      <a-form-item field="expectedJob" label="期望岗位" >
        <a-input v-model="seekerform.expectedJob" placeholder="请输入期望岗位..." />
      </a-form-item>
      <a-form-item field="expectedCity" label="期望城市" >
        <a-input v-model="seekerform.expectedCity" placeholder="请输入期望城市..." />
      </a-form-item>
      <a-form-item field="expectedSalaryMin" label="最低期望薪资" >
        <a-input v-model="seekerform.expectedSalaryMin" placeholder="请输入最低期望薪资..." />
      </a-form-item>
      <a-form-item field="expectedSalaryMax" label="最高期望薪资" >
        <a-input v-model="seekerform.expectedSalaryMax" placeholder="请输入最高期望薪资..." />
      </a-form-item>
      <a-form-item field="employmentType" label="雇佣类型" >
        <a-input v-model="seekerform.employmentType" placeholder="请输入雇佣类型..." />
      </a-form-item>
      <a-form-item field="educationBackground" label="教育背景" >
        <a-input v-model="seekerform.educationBackground" placeholder="请输入教育背景..." />
      </a-form-item>
      <a-form-item field="major" label="专业" >
        <a-input v-model="seekerform.major" placeholder="请输入专业..." />
      </a-form-item>
      <a-form-item field="degree" label="学位" >
        <a-input v-model="seekerform.degree" placeholder="请输入学位..." />
      </a-form-item>
      <a-form-item field="availableStartDate" label="预计可到岗日期" >
        <a-input v-model="seekerform.availableStartDate" placeholder="请输入预计可到岗日期..." />
      </a-form-item>

    </a-form>
  </a-modal>
  <!--  HRform弹窗-->

  <a-modal v-model:visible="visibleHR" title="账号信息" @cancel="handleCancelHR" @before-ok="handleBeforeOkHR">
    <a-form :style="{width:'400px',height:'400px'}">
      <!--                 hrId:'', // hrID
                 companyId:'', // 公司id
                 corporateName:'', // 公司名称
                 avgResponseTimeHours:'', // 平均回复候选人时间（小时）
                 recentReplyCount:'', // 过去一周内回复候选人的次数
                 position:'', // 职位
                 examineState:'', // 审核状态
                 recommend:'', // 智能推荐
                 userId:'', // 用户ID
                 createTime:'', // 创建时间
                 updateTime:'', // 更新时间-->
      <a-form-item field="companyId" label="公司id" >
        <a-input v-model="HRform.companyId" placeholder="请输入公司id..." />
      </a-form-item>
      <a-form-item field="corporateName" label="公司名称" >
        <a-input v-model="HRform.corporateName" placeholder="请输入公司名称..." />
      </a-form-item>
      <a-form-item field="position" label="职位" >
        <a-input v-model="HRform.position" placeholder="请输入职位..." />
      </a-form-item>
    </a-form>
  </a-modal>
</template>


<script >
import { onMounted, ref } from 'vue';
import router from "@/router";
import axios from "axios";
import moment from "moment";
import qs from "qs";
import {ElMessage} from "element-plus";

export default {
  setup() {
    const visibleuserform = ref(false);
    const visibleseeker = ref(false);
    const visibleHR = ref(false);


    /**图片上传相关代码开始**/
    let fileList = ref([]);
    const dialogImageUrl = ref('');
    const dialogVisibleImg = ref(false);
//移除图片
    const handleRemove = (uploadFile, uploadFiles) => {
      console.log(uploadFile, uploadFiles);
      //1.得到要删除的图片路径 uploadFile就是我们上传的图片文件对象
      let imgUrl = uploadFile.response.data;
      //2.给后端发请求,删除图片
      axios.post(BASE_URL+'/v1/file/remove?imgUrl='+imgUrl).then((response)=>{
        if (response.data.code==2000){
          ElMessage.success('删除成功!');
        }
      })

    }
//图片上传后预览
    const handlePictureCardPreview = (uploadFile) => {
      dialogVisibleImg.value = true;
      console.log(uploadFile);
    }
    /**图片上传相关代码结束**/
    const handleSubmit = ({values, errors}) => {
      console.log('values:', values, '\nerrors:', errors)
    }
    const curuser = ref({});
    onMounted(async () => {
      curuser.value = JSON.parse(localStorage.getItem("user"));
      // console.log(localStorage.user);
      // console.log("user",curuser.value);
      // console.log("user--------------",userform.value);
      userform.value = curuser.value;
      // console.log("userform",userform);
      if(userform.value==null){
        router.push("/login");
      }else {
        loadseekInfo();
        loaduserInfo();
        getDeliverRejectedData();
        getDeliverData();
        getDeliverOfPassedData();
        getMyCollectedData();
      }

    });
    const goToJobDetail = (id)=>{
      if(user.value == null){
        ElMessage.warning("请先注册登录！");
      }else{
        router.push({ path: 'JobDetail', query: { id:id } });
      }
    }
    const deliverData = ref([])
    const userInfo = ref(getUser());
    // const deliverParms = ref({})
    // 获取已投递记录
    const getDeliverData = (resumeStatus) => {
      let userId = userInfo.value.userId
      // deliverParms.value.userId = userId;
      // deliverParms.value.resumeStatus = resumeStatus;
      axios.get(BASE_URL + '/v1/user/center/getDelivers/' + userId).then((res)=>{
        if (res.data.code == 2000) {
          console.log(res.data.data)
          deliverData.value = res.data.data;
        }else{
          console.log(res.data.code);
          ElMessage.error("投递记录加载失败");
        }
      })
    }
    const deliverOfPassedData = ref([])
    // 获取已投递记录
    const getDeliverOfPassedData = () => {
      let userId = userInfo.value.userId;
      axios.get(BASE_URL + '/v1/user/center/getDeliverOfPassed/'+ userId).then((res)=>{
        if (res.data.code == 2000) {
          console.log(res.data.data)
          deliverOfPassedData.value = res.data.data;
        }else{
          console.log(res.data.code);
          ElMessage.error("投递记录加载失败");
        }
      })
    }
    // 获取已拒绝
    const deliverRejectedData = ref([])
    const getDeliverRejectedData = () => {
      let userId = userInfo.value.userId;
      axios.get(BASE_URL + '/v1/user/center/getDeliverRejected/'+ userId).then((res)=>{
        if (res.data.code == 2000) {
          console.log(res.data.data)
          deliverRejectedData.value = res.data.data;
        }else{
          console.log(res.data.code);
          ElMessage.error("投递记录加载失败");
        }
      })
    }
    // 获取收藏
    const collectedData = ref([])
    const getMyCollectedData = () => {
      let userId = userInfo.value.userId;
      axios.get(BASE_URL + '/v1/user/center/getMyCollectedData/'+ userId).then((res)=>{
        if (res.data.code == 2000) {
          console.log("收藏=========================")
          console.log(res.data.data)
          collectedData.value = res.data.data;
        }else{
          console.log(res.data.code);
          ElMessage.error("投递记录加载失败");
        }
      })
    }
    // 格式转换
    const formatCreateTime = (time) => {
      return moment(time).format('YYYY-MM-DD');
    }
    const user = ref({
      id:'', // 用户id
      userId:'',
      username:'', // 用户名
      nickname:'', // 昵称
      password:'', // 密码
      password1:'', // 密码
      password2:'', // 密码
      userImg:'', // 头像，默认值为'userDefaultImg.jpg'
      email:'', // 电子邮箱
      phone:'', // 手机号码
      realName:'', // 真实姓名
      identityId:'',
      gender:'', // 性别，建议使用枚举类型进行优化
      wechatId:'', // 微信号
      size: 'medium',
    });

    const userform = ref({
      id:'', // 用户id
      userId:'',
      username:'', // 用户名
      nickname:'', // 昵称
      password:'', // 密码
      password1:'', // 密码
      password2:'', // 密码
      userImg:'', // 头像，默认值为'userDefaultImg.jpg'
      email:'', // 电子邮箱
      phone:'', // 手机号码
      realName:'', // 真实姓名
      identityId:'',
      gender:'', // 性别，建议使用枚举类型进行优化
      wechatId:'', // 微信号
      size: 'medium',
    });

    const seekerform = ref([
      // id:'', // 应聘者ID，主键，自动递增
      // UserId:'', // 用户id
      // identity:'', // 身份
      // lookforStatus:'', // 求职状态
      // personalAdvantage:'', // 个人优势
      // graduateTime:'', // 毕业时间
      // birthday:'', // 出生日期
      // birthdayPlace:'', // 出生地
      // expectedJob:'', // 期望岗位
      // expectedCity:'', // 期望城市
      // expectedSalaryMin:'', // 最低期望薪资
      // expectedSalaryMax:'', // 最高期望薪资
      // employmentType:'', // 雇佣类型
      // educationBackground:'', // 教育背景
      // major:'', // 专业
      // degree:'', // 学位
      // availableStart:'', // 预计可到岗日期
      // createTime:'', // 创建时间
    ]);
    const seeker = ref([]
        // id:'', // 应聘者ID，主键，自动递增
        //     UserId:'', // 用户id
        //     identity:'', // 身份
        //     lookforStatus:'', // 求职状态
        //     personalAdvantage:'', // 个人优势
        //     graduateTime:'', // 毕业时间
        //     birthday:'', // 出生日期
        //     birthdayPlace:'', // 出生地
        //     expectedJob:'', // 期望岗位
        //     expectedCity:'', // 期望城市
        //     expectedSalaryMin:'', // 最低期望薪资
        //     expectedSalaryMax:'', // 最高期望薪资
        //     employmentType:'', // 雇佣类型
        //     educationBackground:'', // 教育背景
        //     major:'', // 专业
        //     degree:'', // 学位
        //     availableStartDate:'', // 预计可到岗日期
        //     createTime:'', // 创建时间
    );


    const HRform = ref({
      hrId:'', // hrID
      companyId:'', // 公司id
      corporateName:'', // 公司名称
      avgResponseTimeHours:'', // 平均回复候选人时间（小时）
      recentReplyCount:'', // 过去一周内回复候选人的次数
      position:'', // 职位
      examineState:'', // 审核状态
      recommend:'', // 智能推荐
      userId:'', // 用户ID
      createTime:'', // 创建时间
      updateTime:'', // 更新时间
    });
    const HR = ref({
      hrId:'', // hrID
      companyId:'', // 公司id
      corporateName:'', // 公司名称
      avgResponseTimeHours:'', // 平均回复候选人时间（小时）
      recentReplyCount:'', // 过去一周内回复候选人的次数
      position:'', // 职位
      examineState:'', // 审核状态
      recommend:'', // 智能推荐
      userId:'', // 用户ID
      createTime:'', // 创建时间
      updateTime:'', // 更新时间
    });
    //请求用户信息
    const loadseekInfo = () => {
      if(userform.value.identityId=='10'){
        let data = qs. stringify({
          UserId:userform.value.userId,
        });
        console.log("7777777777777")
        console.log(data);
        axios.post( BASE_URL + '/v1/user/seeker/select/',data).then(response => {
          console.log(response.data.code);
          if (response.data.code == 2000) {
            seekerform.value = response.data.data[0];
            // console.log("seekerform)))"+seekerform.value.id);
            // console.log("data"+response.data.data[0])
            // console.log("seeker")
            // console.log("seeker"+seekerform);
            localStorage.setItem('seekerform',JSON.stringify(seekerform));
            // console.log("seeker"+localStorage.getItem('seekerform'));
            seeker.value = seekerform.value;
          }else {
            console.log("请求失败");
            console.log(response.data.code);
            ElMessage.error(response.data.message);
          }
        })
      }else if(userform.value.identityId=='20'){
        let data = qs.stringify({
          UserId:userform.value.userId,
        });
        axios.post( BASE_URL + '/v1/user/hr/select/',data).then(response => {
          console.log(response.data.code);
          if (response.data.code == 2000) {
            console.log(response.data.data);
            HRform.value = response.data.data[0];
            console.log("HR")
            console.log("HR"+HRform.value);
            localStorage.setItem('HRform',JSON.stringify(HRform));
            HR.value = HRform.value;
          }else{
            console.log("请求失败");
            console.log(response.data.code);
            ElMessage.error(response.data.message);

          }

        })
      }
    }
    const loaduserInfo = () => {
      let data = qs.stringify({
        UserId:userform.value.userId,
      });
      console.log("6448498498498984"+user.value.UserId);
      axios.post( BASE_URL + '/v1/user/select/',data).then(response => {
        console.log(response.data.code);
        if (response.data.code == 2000) {
          userform.value = response.data.data[0];
          user.value = userform.value;
          // console.log("userform"+userform.value.id);
          // console.log("data"+response.data.data[0])
          // console.log("userform"+userform);
          localStorage.setItem('userform',JSON.stringify(userform));
          // console.log("userform"+localStorage.getItem('userform'));
          loadseekInfo();
        }else {
          console.log("请求失败");
          console.log(response.data.code);
          ElMessage.error(response.data.message);
        }
      })
    }
    const loadHR = () => {
      let data = qs.stringify({
        UserId:userform.value.userId,
      });
      axios.post( BASE_URL + '/v1/user/hr/select/',data).then(response => {
        console.log(response.data.code);
        if (response.data.code == 2000) {
          HRform.value = response.data.data[0];
          HR.value = HRform.value;
          console.log("HR")
          console.log("HR"+HRform.value);
          localStorage.setItem('HRform',JSON.stringify(HRform));
          console.log("HR"+localStorage.getItem('HRform'));
        }else{
          console.log("请求失败");
          console.log(response.data.code);
        }
      })
    }


    const handleClick = () => {
      visibleuserform.value = true;
    };
    const handleClickseeker =() => {
      visibleseeker.value = true;
    };
    const handleClickHR =() => {
      visibleHR.value = true;
    };
    const handleBeforeOk = (done) => {
      userform.value.userImg = fileList.value[0].response.data;
      // console.log("//////////////////////////////////////////////////");
      // console.log(userform.value.userImg)
      // console.log(userform)

      let data = qs.stringify({
        id:userform.value.id,
        identityId:userform.value.identityId,
        UserId:userform.value.userId,
        email:userform.value.email,
        phone:userform.value.phone,
        userImg:userform.value.userImg,
        realName:userform.value.realName,
        gender:userform.value.gender,
        wechatId:userform.value.wechatId,
        password:userform.value.password,
        password1:userform.value.password1,
        password2:userform.value.password2
      });
      axios.post( BASE_URL + '/v1/user/update/',data).then(response => {
        console.log(response.data.code);
        if (response.data.code == 2000) {
          ElMessage.success('修改成功');
          visibleuserform.value = false;
          loaduserInfo();
          window.location.href = window.location.href;
        }else{
          console.log("请求失败");
          console.log(response.data.code);
          ElMessage.error(response.data.message);
        }
      })
      window.setTimeout(() => {
        done()
        // prevent close
        // done(false)
      }, 1000)
    };

    const handleBeforeOkseeker = (done) => {
      console.log(userform)
      console.log(seekerform)
      let data = qs.stringify({
        id:seekerform.value.id,
        identityId:userform.value.identityId,
        UserId:userform.value.userId,
        lookforStatus:seekerform.value.lookforStatus,
        personalAdvantage:seekerform.value.personalAdvantage,
        graduateTime:seekerform.value.graduateTime,
        birthday:seekerform.value.birthday,
        birthdayPlace:seekerform.value.birthdayPlace,
        expectedJob:seekerform.value.expectedJob,
        expectedCity:seekerform.value.expectedCity,
        expectedSalaryMin:seekerform.value.expectedSalaryMin,
        expectedSalaryMax:seekerform.value.expectedSalaryMax,
        employmentType:seekerform.value.employmentType,
        educationBackground:seekerform.value.educationBackground,
        major:seekerform.value.major,
        degree:seekerform.value.degree,
        availableStart:seekerform.value.availableStart,
      });
      axios.post( BASE_URL + '/v1/user/seeker/save/',data).then(response => {
        console.log(response.data.code);
        if (response.data.code == 2000) {
          ElMessage.success('修改成功');
          visibleseeker.value = false;
          loadseekInfo();
        }else{
          console.log("请求失败");
          console.log(response.data.code);
          ElMessage.error(response.data.message);
        }
      })
      window.setTimeout(() => {
        done()
        // prevent close
        // done(false)
      }, 1000)
    };
    const handleBeforeOkHR = (done) => {
      console.log(userform)
      let data = qs.stringify({
        // hrId:'', // hrID
        // companyId:'', // 公司id
        // corporateName:'', // 公司名称
        // avgResponseTimeHours:'', // 平均回复候选人时间（小时）
        // recentReplyCount:'', // 过去一周内回复候选人的次数
        // position:'', // 职位
        // examineState:'', // 审核状态
        // recommend:'', // 智能推荐
        // userId:'', // 用户ID
        // createTime:'', // 创建时间
        // updateTime:'', // 更新时间
        hrId:HRform.value.hrId,
        UserId:userform.value.userId,
        companyId:HRform.value.companyId,
        identityId:userform.value.identityId,
        corporateName:HRform.value.corporateName,
        position:HRform.value.position,
      });
      axios.post( BASE_URL + '/v1/user/hr/save/',data).then(response => {
        console.log(response.data.code);
        if (response.data.code == 2000) {
          ElMessage.success('修改成功');
          visibleHR.value = false;
          loadHR();
        }else{
          console.log("请求失败");
          console.log(response.data.code);
          ElMessage.error(response.data.message);
        }
      })
      window.setTimeout(() => {
        done()
        // prevent close
        // done(false)
      }, 1000)
    };
    const handleCancel = () => {
      visibleuserform.value = false;
    }
    const handleCancelseeker = () => {
      visibleseeker.value = false;
    }
    const handleCancelHR = () => {
      visibleHR.value = false;
    }

    return {
      visibleuserform,
      userform,
      seekerform,
      deliverRejectedData,
      deliverData,
      deliverOfPassedData,
      collectedData,
      formatCreateTime,
      getDeliverData,
      goToJobDetail,
      getDeliverOfPassedData,
      getDeliverRejectedData,
      getMyCollectedData,
      fileList,
      handleClick,
      handleBeforeOk,
      handleCancel,
      handleClickseeker,
      handleBeforeOkseeker,
      handleCancelseeker,
      handleClickHR,
      handleBeforeOkHR,
      handleCancelHR,
      HRform,
      loadseekInfo,
      user,
      seeker,
      HR,
      visibleseeker,
      visibleHR,
      loadHR,
      loaduserInfo,
    }
  }
}
</script>

<style scoped>
*{
  padding: 0;
  margin: 0;
  text-decoration:none;
}
.main{
  width: 100%;
  height: 100%;
  margin-top: -0.1%;
  background: url("../../assets/img/user/userCenterBJ.jpg") center;
  min-height: 94vh;
  background-size: 100% 100%;
}
.Card{
  border-radius: 10px;
}
.CardRS{
  width: 100%;
  background-color: white;
  border-radius: 10px;
  height: 91%;
}
.scrollbar-demo-item {
  width: 98%;
  height: 120px;
  margin: 9px;
  border-radius: 4px;
  background-color: rgba(116, 62, 148, 0.24) !important;
  color:#612e94!important;
}
.scrollbar-demo-list{
  width: 98%;
  height: 150px;
  margin: 9px;
  border-radius: 4px;
  background-color: rgba(116, 62, 148, 0.24) !important;
  color:#612e94!important;
}
.scrollbar-demo-list2{
  width: 98%;
  height: 120px;
  margin: 9px;
  border-radius: 4px;
  background-color: rgba(116, 62, 148, 0.24) !important;
  color:#612e94!important;
}
.scrollbar-demo-ms1{
  width: 98%;
  height: 70px;
  margin: 9px;
  border-radius: 4px;
  background-color: rgba(116, 62, 148, 0.24) !important;
  color:#612e94!important;
}
.scrollbar-demo-zw1{
  width: 98%;
  height: 116px;
  margin: 9px;
  border-radius: 4px;
  background-color: rgba(116, 62, 148, 0.24) !important;
  color:#612e94!important;
}
.scrollbar-demo-R1{
  width: 95%;
  height: 70px;
  margin: 10px;
  border-radius: 4px;
  background-color: rgba(116, 62, 148, 0.2) !important;
  color:#612e94!important;
}
</style>